package com.hsy.sunflowerbao.home.store

import com.flux.action.RxAction
import com.flux.action.RxStoreChange
import com.flux.dispatcher.Dispatcher
import com.hsy.sunflowerbao.base.action.ActionType
import com.hsy.sunflowerbao.base.action.Key
import com.hsy.sunflowerbao.base.data.UserData
import com.hsy.sunflowerbao.base.store.BaseStore

/**
 * 首页数据缓存
 * Created on 2018/3/26.
 *
 * @author Yang
 */
class HomeStore(dispatcher: Dispatcher) : BaseStore(dispatcher) {
    /**
     * 用户信息
     */
    lateinit var user: UserData

    override fun onRxAction(action: RxAction) {
        if (action.type == ActionType.GET_SEARCH_USER) {
            if (action.success) {
                //登录成功
                user = action[Key.USER_DATA]
            }
        }
        postChange(RxStoreChange(tag, action.type, action.success))
    }
}